import { Base } from '../../utils/base.js';

class Photo extends Base {
  constructor() {
    super();
  }

  getPhotoInfo(id, callback) {
    var param = {
      url: 'pets_photo/info?id=' + id,
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(param);
  }

  getPotoList(id, callback) {
    var param = {
      url: 'pets_photo/list?pets_id=' + id,
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(param);
  }

  postComments(id, param, callback) {
    var allParam = {
      url: 'pets_photo/postComents?pets_id=' + id,
      data: param,
      type: 'POST',
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  updateComments(id, callback) {
    var allParam = {
      url: 'pets_photo/update_comments_status?photo_id=' + id,
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  getNewComments(callback) {
    var allParam = {
      url: 'pets_photo/newcomments',
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  getCommentsPage(photoId, pageIndex, callback) {
    var allParam = {
      url: 'pets_photo/photoComments?photo_id=' + photoId + '&page=' + pageIndex + '&size=3',
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  getPotoList(id, callback) {
    var param = {
      url: 'pets_photo/list?pets_id=' + id,
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(param);
  }

  postComments(param, callback) {
    var allParam = {
      url: 'pets_photo/postComents',
      data: param,
      type: 'POST',
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  deleteComment(id, callback) {
    var allParam = {
      url: 'pets_photo/delcomment?id=' + id,
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  getNewComments(callback) {
    var allParam = {
      url: 'pets_photo/newcomments',
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  getCommentsPage(photoId, pageIndex, callback) {
    var allParam = {
      url: 'pets_photo/photoComments?photo_id=' + photoId + '&page=' + pageIndex + '&size=3',
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }

  deletePhoto(id, callback) {
    var allParam = {
      url: 'pets_photo/delphoto?id=' + id, 
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(allParam);
  }
}

export { Photo }